﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using colorMultiField;
using snake_class;

namespace Console_Snake
{
    class Program
    {
        static void Main(string[] args)
        {
            MainGame myGame = new MainGame();
            myGame.GoGame();
        }
    }
    class MainGame
    {
        myConsole myConsoleObject;
        snake snakeObject;

        public MainGame()
        {
        }

        public void GoGame()
        {
            this.myConsoleObject = new myConsole();
            this.myConsoleObject.writeField();

            this.snakeObject = new snake();
            this.myConsoleObject.writeSnake(snakeObject);

            while (true)
            {
                ConsoleKeyInfo preskey = Console.ReadKey();
                if (preskey.Key == ConsoleKey.UpArrow)
                {
                    this.snakeObject.vectX = 0;
                    this.snakeObject.vectY = -1;
                }
                else if (preskey.Key == ConsoleKey.DownArrow)
                {
                    this.snakeObject.vectX = 0;
                    this.snakeObject.vectY = 1;
                }
                else if (preskey.Key == ConsoleKey.LeftArrow)
                {
                    this.snakeObject.vectX = -1;
                    this.snakeObject.vectY = 0;
                }
                else if (preskey.Key == ConsoleKey.RightArrow)
                {
                    this.snakeObject.vectX = 1;
                    this.snakeObject.vectY = 0;
                }
                else if (preskey.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (preskey.Key == ConsoleKey.Spacebar)
                {
                    //int re = this.snakeObject.currentLength;
                    this.snakeObject.snakeGoNext();
                    this.myConsoleObject.ClearConsole();
                    this.myConsoleObject.writeField();
                    this.myConsoleObject.writeSnake(snakeObject);
                }
            }
        }
    }
}
